package com.example.service.impl;

import com.example.entity.JobOption;
import com.example.mapper.EmployeeMapper;
import com.example.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = employeeMapper.countEmpJobData();
        List<Object> jnameList = list.stream().map(dataMap -> dataMap.get("jname")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();

        return new JobOption(jnameList, dataList);
    }
    @Override
    public List<Map> getEmpGenderData() {
        return employeeMapper.countEmpGenderData();
    }
}